<?php
 session_start();
 date_default_timezone_set('PRC');
 include_once '../inc/conn.php';

 ?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>oa</title>
<link rel="stylesheet" rev="stylesheet" href="../css/style.css" type="text/css"  />
<script type="text/javascript" src="../js/message.js">


</script>
</head>

<body class="ContentBody">
  <form  action="" method="post"  name="fom1"  onsubmit="return check_message(this);">
<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
      <th class="tablestyle_title" >新建信息</th>
  </tr>
  <tr>
    <td class="CPanel">
		
		<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
		
		<TR>
			<TD width="100%">
				<fieldset style="height:100%;">
				<legend>新建信息</legend>
					  <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
					    
					    
					  <tr>
					    <td nowrap align="right" width="11%">消息标题:</td>
					    <td width="27%"><input name='message_title' type="text" class="text" style="width:154px" value="" /></td>
				        	
					    <td align="right" width="25%">&nbsp;</td>
					    <td width="37%">&nbsp;</td>
					    </tr>
					    
					    
					    
					  <tr>
					    <td width="11%" align="right" nowrap>接收者:</td>
					    <td colspan="3"><input name='receiver' type="text" class="text" style="width:450px;" size="20" value="" />
					      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name="message_level">
							
							<option selected="selected" value=0>不重要</option>
							<option value=1>重要</option>
							
						</select></td>
					    </tr>
					  
					  <tr>
					    <td  width="11%" nowrap align="right">信息内容:</td>
					    <td colspan="3"><textarea name="message_content" cols="100" rows="15"></textarea></td>
					    </tr>
					  </table>
			  <br />
			</fieldset>			</TD>
			
		</TR>
		</TABLE>

	 </td>
  </tr>
  

		
		<TR>
			<TD colspan="2" align="center" height="50px">
			<input type="submit" name="sendok" value="发送"  />　
			
			<input type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/></TD>
		</TR>
		</TABLE>
	

</div>
</form>


<?php

if (isset($_POST['sendok'])){

	$message_title = addslashes(trim($_POST['message_title']));
	$receiver  =  addslashes(trim($_POST['receiver']));
	$level =      addslashes(trim($_POST['message_level']));
	$content    = addslashes(trim($_POST['message_content']));
	$send_time=   strtotime(date('Y-m-d H:i:s'));
	$sender     = $_SESSION["username"];
	
	 mysql_query("SET NAMES 'UTF8'");
	  $message_add="insert into message(message_title,send_time,sender,receiver,message_level,message_content) values ('$message_title',$send_time,'$sender','$receiver ',$level,'$content')";
//    print_r($message_add);exit;
	  $result_message=$oa->query( $message_add);
	  if($result_message){ echo "<script>alert('发送成功!'); window.location.href='listtakexiaoxi.php';</script>";}
      else{echo "mysql_error();";}
	
	
}

?>

</body>
</html>
